const qs = require('qs');
const esStringify = require('./custome-qs')
const assert = require('assert');


// 编码
const params = { sex: ['male', 'female'] };
let str1 = esStringify(params, { arrayFormat: 'repeat' })
let str2 = esStringify(params, { arrayFormat: 'comma' }) // sex=male,female
let str3 = esStringify(params, { arrayFormat: 'brackets' })  // sex[]=male&sex[]=female
let str4 = esStringify(params, { arrayFormat: 'indices' }) // sex[0]=male&sex[1]=female
let str42 = qs.stringify(params, { arrayFormat: 'indices' }) // sex[0]=male&sex[1]=female
let str5 = esStringify({ a: { b: 1 } }, { arrayFormat: 'indices' }) // sex[0]=male&sex[1]=female
console.log(str1, str2, str3, str4)
// assert.strictEqual(str, 'sex=male&sex=female');


// 解析
// let obj = qs.parse(str)
// assert.notStrictEqual(obj, { a: "yaogang" })

